import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "@/layouts";
import EmptyLayout from "@/layouts/EmptyLayout";

Vue.use(VueRouter);

export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
    meta: { title: "登录" },
  },
  {
    path: "/my",
    component: () => import("@/views/admin/userList/index"),
    hidden: true,
    meta: { title: "个人中心" },
  },
  {
    path: "/myOrder",
    component: () => import("@/views/wap/order"),
    hidden: true,
    meta: { title: "我的订单" },
  },
  {
    path: "/myReport",
    component: () => import("@/views/wap/report"),
    hidden: true,
    meta: { title: "数据报表" },
  },
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index"),
      },
    ],
  },
];

/*当settings.js里authentication配置的是intelligence时，views引入交给前端配置*/
export const asyncRoutes = [
  // {
  //   component: "Layout",
  //   path: "/pidlist",
  //   redirect: "noRedirect",
  //   children: [
  //     {
  //       component: "pidList/index",
  //       meta: { title: "pid设置", icon: "meteor" },
  //       name: "PidList",
  //       path: "/pidlist",
  //     },
  //   ],
  // },
  // {
  //   component: "Layout",
  //   path: "/",
  //   redirect: "/",
  //   children: [
  //     {
  //       component: "admin/index",
  //       name: "Index",
  //       path: "/",
  //       meta: {
  //         affix: true,
  //         icon: "home",
  //         noCache: true,
  //         title: "首页",
  //       },
  //     },
  //   ],
  // },
  // {
  //   component: "Layout",
  //   path: "/ranking",
  //   redirect: "noRedirect",
  //   children: [
  //     {
  //       component: "ranking/index",
  //       name: "Ranking",
  //       path: "/",
  //       meta: {
  //         icon: "medal",
  //         title: "龙虎榜",
  //       },
  //     },
  //   ],
  // },
  // {
  //   component: "Layout",
  //   path: "/search",
  //   redirect: "noRedirect",
  //   children: [
  //     {
  //       component: "search/index",
  //       meta: { title: "商品搜索", icon: "search" },
  //       name: "Search",
  //       path: "/search",
  //     },
  //   ],
  // },
  // {
  //   component: "Layout",
  //   path: "/orderList",
  //   redirect: "noRedirect",
  //   children: [
  //     {
  //       name: "OrderList",
  //       path: "/orderList",
  //       component: "orderList/index",
  //       meta: { title: "订单列表", icon: "tasks" },
  //     },
  //   ],
  // },
  // {
  //   component: "Layout",
  //   path: "/goodsRanking",
  //   redirect: "noRedirect",
  //   children: [
  //     {
  //       component: "goodsRanking/index",
  //       meta: { title: "商品排行", icon: "boxes" },
  //       name: "SortGoods",
  //       path: "/goodsRanking",
  //     },
  //   ],
  // },
  // {
  //   alwaysShow: false,
  //   children: [
  //     {
  //       component: "taolijin/orderList",
  //       meta: { title: "创建成功", icon: "list-ul" },
  //       name: "TaolijinOrderList",
  //       path: "/taolijin/orderList",
  //     },
  //     {
  //       component: "taolijin/crontab",
  //       meta: { title: "定时任务", icon: "meteor" },
  //       name: "TaolijinCrontab",
  //       path: "/taolijin/crontab",
  //     },
  //   ],
  //   component: "Layout",
  //   listShow: false,
  //   meta: { title: "淘礼金", icon: "donate" },
  //   name: "Taolijin",
  //   path: "/taolijin",
  //   redirect: "noRedirect",
  // },
  // {
  //   alwaysShow: false,
  //   children: [
  //     {
  //       component: "admin/userList/index",
  //       meta: { title: "用户管理", icon: "users" },
  //       name: "Userlist",
  //       path: "/admin/userList",
  //     },
  //     {
  //       component: "admin/unionTaobao/index",
  //       meta: { title: "淘宝账号", icon: "briefcase" },
  //       name: "UnionTaobao",
  //       path: "/admin/unionTaobao",
  //     },
  //   ],
  //   component: "Layout",
  //   listShow: true,
  //   meta: { title: "管理员", icon: "shield-alt" },
  //   name: "Admin",
  //   path: "/admin",
  //   redirect: "noRedirect",
  // },
  // {
  //   component: "Layout",
  //   path: "/dataDetails",
  //   redirect: "noRedirect",
  //   children: [
  //     {
  //       component: "dataDetails/index",
  //       meta: { title: "数据报表", icon: "align-justify" },
  //       name: "dataDetails",
  //       path: "/dataDetails",
  //     },
  //   ],
  // },
  // {
  //   component: "404",
  //   hidden: true,
  //   meta: { title: "页面不见了" },
  //   name: "404",
  //   path: "/*",
  // },
];

const router = new VueRouter({
  mode: "history",
  scrollBehavior: () => ({
    y: 0,
  }),
  routes: constantRoutes,
});

export function resetRouter() {
  router.matcher = new VueRouter({
    mode: "history",
    scrollBehavior: () => ({
      y: 0,
    }),
    routes: constantRoutes,
  }).matcher;
}

export default router;
